package com.dog.basics.admin.controller.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.common.AppVersionInfoAdminPageDto;
import com.dog.basics.bean.dto.admin.common.AppVersionInfoAdminAddDto;
import com.dog.basics.bean.vo.admin.common.DogAppVersionInfoPageVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.constant.CommonConstants;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.common.IDogAppVersionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * APP版本模块
 *
 * @author dog
 */
@RestController
@RequestMapping("/admin/version")
@Api(value = SwaggerConstants.COMMON+"APP版本模块", tags = SwaggerConstants.COMMON+"APP版本模块")
@AllArgsConstructor
public class PcVersioController {

    private final IDogAppVersionInfoService cljgAppVersionInfoService;


    /**
     * @Author: guoy
     * @Param: [page, dogAppVersionInfoDto]
     * @Return: com.tea.machine.common.util.R<com.baomidou.mybatisplus.core.metadata.IPage<com.tea.machine.bean.model.DogAppVersionInfo>>
     * @Date: 2019/12/23 15:48
     * 功能描述：查询APP版本升级列表
     * @update guonh 2020年1月9日 (1.不规范)
     */
    @SysLog("查询APP版本升级列表")
    @ApiOperation(value = "查询APP版本升级列表", notes = "APP版本信息列表")
    @GetMapping(value = {"/selectAppVersionInfoPage"})
    public R<IPage<DogAppVersionInfoPageVo>> selectAppVersionInfoPage(PageParam page, AppVersionInfoAdminPageDto dogAppVersionInfoDto) {
        return R.ok(cljgAppVersionInfoService.selecyVersionPage(page,dogAppVersionInfoDto));
    }


    /**
     * @Author: guoy
     * @Param: [DogAppVersionInfoAddDto]
     * @Return: com.tea.machine.common.util.R
     * @Date: 2019/12/23 11:15
     * 功能描述：添加APP版本
     * @update guonh 2020年1月9日 (1.不规范 2.上传时候版本等信息自动获取)
     */
    @SysLog("添加APP版本")
    @ApiOperation(value = "添加APP版本",notes = "添加APP版本")
    @PostMapping("/saveAppVersionInfo")
    public R addAppVersionInfo(@Valid @RequestBody AppVersionInfoAdminAddDto appVersionInfoAdminAddDto){
        return R.ok(cljgAppVersionInfoService.saveAuthObtainInfo(appVersionInfoAdminAddDto));
    }


    /**
     * @Author: guoy
     * @Param: [id]
     * @Return: com.tea.machine.common.util.R
     * @Date: 2019/12/23 16:00
     * 功能描述：删除APP版本
     */
    @SysLog("删除APP版本")
    @ApiOperation(value = "删除APP版本" ,notes = "删除APP版本")
    @DeleteMapping("/deleteAppVersionInfo/{id}")
    public R deleteAppVersionInfo(@PathVariable Long id){
        return R.ok(cljgAppVersionInfoService.removeById(id));
    }

}
